//
//  UpdataViewController.m
//  USB_Reader
//
//  Created by whyUpdate on 15-3-28.
//  Copyright (c) 2015年 Tony_Wang. All rights reserved.
//

#import "UpdataViewController.h"
#import "MainVC.h"
#import "MBProgressHUD.h"
@interface UpdataViewController ()<MBProgressHUDDelegate, UIWebViewDelegate>
@property (nonatomic, retain) UIWebView *webView;
@property (nonatomic, retain) MBProgressHUD *HUD;
@end

@implementation UpdataViewController

- (void)dealloc
{

    [_HUD release];
    [_webView release];
    [super dealloc];
}

- (void)viewWillAppear:(BOOL)animated
{
  
        self.tabBarController.tabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
  self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    
    NSString *str = [@"http://ideat.linkchic.com:8000" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSURL *rul = [NSURL URLWithString:str];
    NSURLRequest *request = [NSURLRequest requestWithURL:rul];
    

    
    self.webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
    
    self.webView.delegate = self;
    [self.view addSubview:self.webView];
    
   
    [self.webView loadRequest:request];
    
    NSLog(@"%@", request);
    [_webView release];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(barButton:)];
    
   
    
    // Do any additional setup after loading the view.
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
//    [self zhuanjuhua];
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    
}


- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [self.HUD hide:YES];
  [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}

- (void)zhuanjuhua
{
    self.HUD = [[[MBProgressHUD alloc] initWithView:self.view] autorelease];
    [self.view addSubview:_HUD];
    self.HUD.labelText = @"努力加载中....";
    self.HUD.minShowTime = 5.0;
    self.HUD.activityIndicatorColor =  [UIColor grayColor];
    self.HUD.alpha = 1;
    self.HUD.progress = 0;
    self.HUD.labelColor = [UIColor grayColor];
    self.HUD.color = [UIColor clearColor];
    self.HUD.userInteractionEnabled = NO;
    self.HUD.delegate = self;
    [self.HUD show:YES];
    
    
}



- (void)barButton:(UIBarButtonItem *)button
{
    [self.webView goBack];
    
  
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
